/**
 * rainbow.com Inc.
 * Copyright (c) 2014-2015 All Rights Reserved.
 */
package com.rainbow.bam.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 系统基础 - Controller
 * 
 * @author HarrisonHan
 * @version $Id: BaseController.java, v 0.1 2015年10月30日 下午1:01:31 HarrisonHan Exp $
 */
@Controller
public class BaseController implements ErrorController {

    public static final String  NO_HANDLER_FOUND_ERROR_VIEW = "404";

    private static final String ERROR_PATH                  = "/error";

    /**
     * 日志
     */
    private static final Logger LOG                         = LoggerFactory
                                                                .getLogger(BaseController.class);


    /**
     * 注册页面
     * 
     * @param request HttpServletRequest对象
     * @param response HttpServletResponse对象
     * @param model SpringFramework Model对象
     * @return
     */
    @RequestMapping(value = "/register", method = RequestMethod.GET)
    public String register(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "base/register";
    }

    /**
     * 密码找回
     * 
     * @param request HttpServletRequest对象
     * @param response HttpServletResponse对象
     * @param model SpringFramework Model对象
     * @return
     */
    @RequestMapping(value = "/forget", method = RequestMethod.GET)
    public String forget(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "base/forget";
    }



    @RequestMapping(value = ERROR_PATH)
    public String handleError() {
        LOG.error("=====================No handler found====================");
        return NO_HANDLER_FOUND_ERROR_VIEW;
    }

    /** 
     * @see org.springframework.boot.autoconfigure.web.ErrorController#getErrorPath()
     */
    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }
}
